package cn.zhoutao.basic.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器
 */
@Configuration//相当于spring的配置文件  applicationContext.xml
public class WebConfigurer implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;
    /**
     * 复写方法
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)//添加拦截器
        .addPathPatterns("/**")
        .excludePathPatterns("/login/**")//登录下的所有都放行
        .excludePathPatterns("/shop/**")
        .excludePathPatterns("/user/register/**")
        .excludePathPatterns("/fastDfs/**")
        .excludePathPatterns("/verifyCode/**");
    }
}